package com.situ.mp.controller;

import com.situ.mp.pojo.Student;
import com.situ.mp.pojo.query.StudentQuery;
import com.situ.mp.service.IStudentService;
import com.situ.mp.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dell
 * @since 2024-09-12
 */
@RestController
@RequestMapping("/student")
@CrossOrigin //解决跨域问题
public class StudentController {

    @Autowired
    private IStudentService studentService;

    @RequestMapping("/getAllStudent")
    public List<Student> getAllStudents() {
        return studentService.list();
    }

    @RequestMapping("/list")
    public Result list(StudentQuery studentQuery) {
        System.out.println("StudentController.list");
        List<Student> list = studentService.list(studentQuery);
        return Result.ok(list);
    }
}
